package com.sunelec.controller;

import com.sunelec.pojo.Users;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.jws.WebParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Author: 郑明利
 * @Description:
 * @Date: Create in 15:49 2018/04/18
 * @Modified By:
 */
@Controller
public class PageController {

    @RequestMapping("/register")
    public String register(){
        return "/register";
    }

    @RequestMapping("/addStation")
    public String addStation(HttpSession session){
        Users users = (Users) session.getAttribute("users");
        int type = users.getType();
        if(type == 3){
            return "/addStation";
        }
        else {
            session.setAttribute("add_message","请使用三级账户进行添加操作！");
            return "forward:/userLogin?login_status=reload";
        }
    }

    @RequestMapping("/checkOut")
    public String checkOut(HttpSession session){
        session.removeAttribute("username");
        session.removeAttribute("powerLists");
        session.removeAttribute("powerLists");
        session.invalidate();
        return "/login";
    }

}
